<?php

/*
 * Created by generator
 *
 */

/**
 * Recupere la liste des enregistrements
 * @param object $db database object
 * @return array of data
 */
if (!function_exists('getAllprofesseursFromDB')) {
	function getAllprofesseursFromDB($db, $orderBy) {
		$sql = "SELECT proidpro, prolbnom, prolbprn, prolbtel, prolbmai, protxcmp, promotxh from gyapro ";
		if( $orderBy != null ) {
			$sql .= "order by " . $orderBy;
		}
		$query = $db->query($sql);

		// recuperer les enregistrements
		$records = array();
		foreach ($query->result_array() as $row) {
			$records[] = $row;
		}
		return $records;
	}
}


/**
 * Insere un nouvel enregistrement
 * @param object $db database object
 * @param string ...
 * @return number identifiant
 */
if (!function_exists('insertNewprofesseur')) {
	function insertNewprofesseur($db, $prolbnom, $prolbprn, $prolbtel, $prolbmai, $protxcmp, $promotxh) {
		$data=array( 'prolbnom'=>$prolbnom, 'prolbprn'=>$prolbprn, 'prolbtel'=>$prolbtel, 'prolbmai'=>$prolbmai, 'protxcmp'=>$protxcmp, 'promotxh'=>$promotxh );
		$db->insert('gyapro',$data);
		return $db->insert_id();
	}
}

/**
 * Mise a jour d'un enregistrement
 */
if (!function_exists('updateprofesseur')) {
	function updateprofesseur($db, $proidpro, $prolbnom, $prolbprn, $prolbtel, $prolbmai, $protxcmp, $promotxh) {
		$sql = "update gyapro set prolbnom = ?, prolbprn = ?, prolbtel = ?, prolbmai = ?, protxcmp = ?, promotxh = ? where proidpro=?";
		$query = $db->query($sql, array($prolbnom, $prolbprn, $prolbtel, $prolbmai, $protxcmp, $promotxh, (int)$proidpro ));
	}
}


/**
 * Suppression d'un enregistrement
 */
if (!function_exists('deleteprofesseur')) {
	function deleteprofesseur($db, $proidpro) {
		$sql = "delete from gyapro where proidpro=?";
		$query = $db->query($sql, array((int)$proidpro));
	}
}


/**
 * Recupere les informations d'un enregistrement
 * @param object $db database object
 * @param int id de l'enregistrement
 * @return array
 */
if (!function_exists('getprofesseurRow')) {
	function getprofesseurRow($db, $proidpro) {
		$sql = "select proidpro, prolbnom, prolbprn, prolbtel, prolbmai, protxcmp, promotxh from gyapro " .
		"where proidpro=?";
		$query = $db->query($sql, array((int)$proidpro));
		if ($query->num_rows() == 0) {
			return null;
		}
		return $query->row_array();
	}
}

	/***************************************************************************
	 * USER DEFINED FUNCTIONS
	 ***************************************************************************/


?>
